package c.j.a.d.b.h;

import com.ss.android.socialbase.downloader.e.a;
import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.RandomAccessFile;

/* compiled from: RandomAccessOutputStream */
public class d implements Closeable {
    public BufferedOutputStream a;
    public FileDescriptor b;
    public RandomAccessFile c;

    public d(File file, int i) throws a {
        try {
            RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
            this.c = randomAccessFile;
            this.b = randomAccessFile.getFD();
            if (i > 0) {
                if (i < 8192) {
                    i = 8192;
                } else if (i > 131072) {
                    i = 131072;
                }
                this.a = new BufferedOutputStream(new FileOutputStream(this.c.getFD()), i);
                return;
            }
            this.a = new BufferedOutputStream(new FileOutputStream(this.c.getFD()));
        } catch (IOException e) {
            throw new a(1039, e);
        }
    }

    public void close() throws IOException {
        c.j.a.d.b.n.a.q(this.c, this.a);
    }
}
